<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>系统管理</title>
<%@ include file="/common/util.jsp"%>

<script src="${cdnctx}/dep/artDialog/jquery.artDialog.js?skin=default"></script>
<script type="text/javascript">
$(document).ready(function(){
	if($("#editFlag").val()== "update"){
		$("#lightcode").attr("readonly","readonly");
		$("#lightcode").css("color","gray");
	}
	for ( var i = 1; i < 12; i++) {
        $("#id" + i).removeClass("current");
    }
    $("#id8").addClass("current");

});
var obj = {
	errflag : false,
	addOrUpdate: function(){
		//obj.checkLightCode();
		obj.dataCheck();
		if(obj.errflag == false){
			$("form:eq(0)").submit();
		}
	},
	
	goback : function(){
		self.location="${cdnctx}/systemDeviceLight/lightEnergMainInit.shtml";	
	},
	 dataCheck:function(){
		 obj.errflag =false;
		//表单验证
		var testNum =/^(([1-9]\d*)|0)(\.\d{1,2})?$/;
		//灯具番号
		if($("#lightcode").val()==""){
			$("#lcmsg").html("此项不能为空！");
			$("#lcmsg").css("display","block");
			obj.errflag =true;
		/*}else if(!testNum.test($("#lightcode").val())){
			$("#lcmsg").html("请输入数字！");
			$("#lcmsg").css("display","block");
			obj.errflag =true;*/
		}else{
			$("#lcmsg").css("display","none");
			
		}
		//灯具名称
		if($("#lightname").val()==""){
			$("#lnmsg").html("此项不能为空！");
			$("#lnmsg").css("display","block");
			obj.errflag =true;
		}else{
			$("#lnmsg").css("display","none");
			
		}
		//灯具功率
		if($("#power").val()!="" && !testNum.test($("#power").val())){
			$("#powermsg").html("请输入数字！");
			$("#powermsg").css("display","block");
			obj.errflag =true;
		}else{
			$("#powermsg").css("display","none");
			
		}
		//灯具数量
		/*if($("#amount").val()!="" && !testNum.test($("#amount").val())){
			$("#amountmsg").html("请输入数字！");
			$("#amountmsg").css("display","block");
			obj.errflag =true;
		}else{
			$("#amountmsg").css("display","none");
			
		}*/
		
	},
	checkLightCode:function(){
	var lightcode = $("#lightcode").val();
		$.ajax({
			type : "POST",
			contentType : "application/json",
			url : "checkLightcode.shtml",
			data : lightcode,
			dataType : "json",
			success: function(data){
				if(data.existFlag == true){
					$("#lcmsg").html("此灯具番号已经存在！");
					$("#lcmsg").css("display","block");
					obj.errflag =true;
				}else{
					$("#lcmsg").css("display","none");
				}
			},
			error: function(){
			}
		});
	}
	
};

</script>
</head>
<body class="main">
	<div class="-frame -style -luster" id="css_container">
		<!--首页框架页眉部分↓-->
		<%@ include file="/WEB-INF/pages/inc/header.jsp"%>
		<!--首页框架页眉部分↑-->

		<div class="content">

			<!-- Left导航菜单◎开始 -->
			<%@ include file="/WEB-INF/pages/inc/leftmenu.jsp"%>
			<!-- Left导航菜单◎结束 -->

			<div class="main-mid">
				<c:if test="${editFlag =='add' }">
					<div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理  ></a><a href="${cdnctx}/systemDeviceLight/deviceLightList.shtml">灯具能耗表管理</a><a>>添加灯具信息</a></div>
				</c:if>
				<c:if test="${editFlag =='update' }">
					<div class="pos"><img src="${cdnctx}/src/index/img/index.png"><a href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理  ></a><a href="${cdnctx}/systemDeviceLight/deviceLightList.shtml">灯具能耗表管理</a><a>>修改灯具信息</a></div>
				</c:if>
				
				<div class="css_contentDiv">
						<form id="lightEnergyUpdate" action="save.shtml"
									method="post">
							<input type="hidden"  name="id" value="${lightEnergy.id}"/>
							<table align="center" width="800" border="0" cellspacing="0"
								cellpadding="0">
								<tr>
									<td width="150" class="mainText" align="right"><label class="font14"><font
											color="red">*</font>灯具番号：</label>
									</td>
									<td><input type="text" class="form_input large" 
										name="lightcode" id="lightcode"
										value="${lightEnergy.lightcode==''?'':lightEnergy.lightcode}"
										 onblur="obj.checkLightCode()" />
										<div id="lcodemsg" style="display: none;color:red"></div></td>
									<td width="120"><div id="lcmsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								<tr>
									<td width="150" class="mainText" align="right"><label class="font14"><font
											color="red">*</font>灯具名称：</label>
									</td>
									<td><input type="text" class="form_input large" 
										name="lightname" id="lightname"
										value="${lightEnergy.lightname}"  />
										<div id="lnmsg" style="display: none;color:red"></div></td>
									<td width="120"><div id="lnamemsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								<tr>
									<td width="150" class="mainText" align="right">
										<label class="font14"><font color="red">*</font>灯具类型：</label>
									</td>
									<td><select id="ePriceType" name="lighttype" class="form_select large">
											<option value="1"
												<c:if test="${1 == lightEnergy.lighttype}">selected</c:if>>传统灯具</option>
											<option value="2"
												<c:if test="${2 == lightEnergy.lighttype}">selected</c:if>>LED灯具</option>
									</select></td>
								</tr>
								<tr>
									<td width="150" class="mainText" align="right"><label class="font14">功率（W）：</label>
									</td>
									<td><input type="text" class="form_input large" 
										name="power" id="power"
										value="${lightEnergy.power ==0?'':lightEnergy.power}" />
										<div id="ePriceCodeError" style="display: none;color:red"></div>
									</td>
									<td width="120"><div id="powermsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								<tr>
									<td width="150" class="mainText" align="right">
										<label class="font14">色温(K)：</label>
									</td>
									<td><input type="text" class="form_input large" 
										id="colortemperature" name="colortemperature"
										value="${lightEnergy.colortemperature}"
										 />
										<div id="unitPriceError" style="display: none;color:red"></div>
									</td>
									<td width="120"><div id="amountmsg"
											style="display:none;color:red;"></div>
									</td>
								</tr>
								<tr>
									<td width="150" class="mainText" align="right">
										<label class="font14">备注：</label>
									</td>
									<td><input type="text" class="form_input large" 
										id="memo" name="memo" value="${lightEnergy.memo}"
										 onblur="" onmouseout="" /></td>
								</tr>
								<tr>
									<td></td>
									<td>
										<input type="button" class="form_save" value="保&nbsp;存" onclick="obj.addOrUpdate()" /> 
										<input type="button" class="form_cancle" value="返&nbsp;回" onclick="obj.goback()" /></td>

								</tr>
							</table>
							</form>
						</div>
				</div>
			</div>

		</div>

		<!--首页框架页尾部分↓-->
		<%@ include file="/WEB-INF/pages/inc/footer.jsp"%>
		<!--首页框架页尾部分↑-->
	</div>
</body>
</html>